package com.wu01.demo.service;

import com.wu01.demo.Entity.User;
import com.wu01.demo.mapper.UserMapper;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.CacheNamespaceRef;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

//@Service
//public class UserService implements UserDetailsService {
//    @Autowired
//    UserMapper userMapper;
//
////    @Cacheable(cacheNames = "user",key = "#id")
////    @Cacheable
//    @Cacheable(cacheNames = "user")
//    public User getUserById(Integer id){
//        System.out.println("select id");
//       return userMapper.getUserById(id) ;
//    }
//    @CachePut(cacheNames = "user",key = "#user.id")
//    public User updateUser(User user){
//        userMapper.updateUser(user);
//        return user;
//    }
//
//    @CacheEvict(cacheNames = "user",key = "#user.id")
//    public User deleteUser(User user) {
//        System.out.println("delete success");
////        return userMapper.deleteUser(user);
//        return user;
//    }
//
////    @Override
////    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
////        User user = new User();
////        User userInfo = userMapper.getUserByUsername(s);
////        user.setUsername(s);
////        user.setPassword(userInfo.getPassword());
////        user.setAuthorities(userInfo.getAuthorities());
////        return user;
////    }
//}
